CREATE TABLE [dbo].[TRPLAN_EXTE]
(
[CO_EMPR] [dbo].[TD_VC_002] NOT NULL,
[NU_ANNO] [dbo].[TD_IN_004_ANNO] NOT NULL CONSTRAINT [DF__TRPLAN_EX__NU_AN__7DCDAAA2] DEFAULT (datepart(year,getdate())),
[CO_PLAN_EXTE] [dbo].[TD_VC_003] NOT NULL,
[CO_CNTA_EXTE] [dbo].[TD_VC_020] NOT NULL,
[CO_CNTA_EMPR] [dbo].[TD_VC_020_CNTA] NOT NULL,
[CO_USUA_CREA] [dbo].[TD_VC_008_USUA] NOT NULL,
[FE_USUA_CREA] [dbo].[TD_DT_001_SIST] NOT NULL CONSTRAINT [DF__TRPLAN_EX__FE_US__00AA174D] DEFAULT (getdate()),
[CO_USUA_MODI] [dbo].[TD_VC_008_USUA] NOT NULL,
[FE_USUA_MODI] [dbo].[TD_DT_001_SIST] NOT NULL CONSTRAINT [DF__TRPLAN_EX__FE_US__019E3B86] DEFAULT (getdate())
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[TRPLAN_EXTE] ADD CONSTRAINT [CK__TRPLAN_EX__CO_CN__7FB5F314] CHECK (([CO_CNTA_EMPR]>='0' AND [CO_CNTA_EMPR]<='99999999999999999999'))
GO
ALTER TABLE [dbo].[TRPLAN_EXTE] ADD CONSTRAINT [CK__TRPLAN_EX__NU_AN__7EC1CEDB] CHECK (([NU_ANNO]>=(0)))
GO
ALTER TABLE [dbo].[TRPLAN_EXTE] ADD CONSTRAINT [XPKTRPLAN_EXTE] PRIMARY KEY CLUSTERED  ([CO_EMPR], [NU_ANNO], [CO_PLAN_EXTE], [CO_CNTA_EXTE], [CO_CNTA_EMPR]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[TRPLAN_EXTE] ADD CONSTRAINT [PK1_TMPLAN_EXTE_A_TRPLAN_EXTE] FOREIGN KEY ([CO_EMPR], [CO_PLAN_EXTE], [CO_CNTA_EXTE]) REFERENCES [dbo].[TMPLAN_EXTE] ([CO_EMPR], [CO_PLAN_EXTE], [CO_CNTA_EXTE])
GO
